{{include file="../include/01_head.tpl"}}
{{include file="../include/02_menu.tpl"}}
<script type="text/javascript">var base_url = "{{""|base_url}}", edialog, ndialog;</script>
<div class="prefix_0">
    <div class="g-d-w- lh28 p-l-12 b-d-b-c-ccc f-w-b f-z-11">Users</div>
    <div class="b-g-c-eee- b-d-b-c-ccc p-4">
        <div class="p-r">
            <div class="grid_10 p-a t-0 l-0 b-0 b-g-c-w- z-i-1 b-d-c-ccc">
                <div class="h-24 b-d-b-c-ccc l-h-24 g-d-w-">
                    <span class="p-l-8 f-w-b">List Users</span>
                    <span class="p-r-8 p-l-20 f-r add c-s-p a" onclick="user_detail('')">Add</span>
                </div>
                <div class="p-a t-24 l-0 r-0 b-0 o-v-f-a">
                    <table class="classic-table wi">
                        <tr class="g-d-w l-h-16">
                            <td class="w-20"></td>
                            <td>Name</td>
                            <td class="w-40">Position</td>
                            <td class="w-40">#</td>
                        </tr>
                        {{foreach $users as $user}}
                            <tr class="l-h-16">
                                <td class="w-20"><input type="checkbox" {{if $user->ause_status==='true'}}checked="1"{{/if}}/></td>
                                <td>{{$user->ause_name}}</td>
                                <td class="w-40">{{$user->ause_position}}</td>
                                <td class="w-40">
                                    <img class="s-w-h c-s-p" 
                                         onclick="user_detail('{{$user->ause_id}}')"
                                         src='{{base_url()}}libraries/images/16/icon_edit.png' alt=""/>
                                </td>
                            </tr>
                        {{/foreach}}{{if not isset($user)}}<tr><td colspan="3" class="t-a-c">No data to display.</td></tr>{{/if}}
                    </table>
                </div>
            </div>
            <div class="b-g-c-eee- p-r r-0 prefix_10">
                <div id="editor_box" class="m-l-6 b-d-c-ccc p-r" style="min-height: 500px">
                    <div class="p-a t-0 l-0 b-0 r-0 tranf-w-50 d-p-n" style="z-index: 1001"></div>
                    <div class="p-a t-0 l-0 b-0 r-0 b-g-ldg b-g-c-w i-l-d d-p-n" style="z-index: 1002"></div>
                    <div class="content-biz"></div>
                    <div class="clear"></div>
                </div>
            </div>
            <div class="clear"></div>
        </div>
    </div>
</div>
<script type="text/javascript">
    function randomString() {
        new backend({
            url         :   "{{"admincp/user/randomstring"|base_url}}",
            data        :   {},
            datatype    :   "text",
            callback    :   function(data){
                $("#ause_password").val(data);
            }
        }).call();
    }
    function user_detail(id){
        backendloading();
        $("#editor_box .content-biz").load(
        "{{base_url()}}admincp/user/editor/" + id,
        function() {
            backendloaded();
            $("#ause_frm").validationEngine();
        }
    );
    }
    function update_ause(){
        if( $('#ause_frm').validationEngine('validate') === false)return false;
        new backend({
            url         :   "{{"admincp/user/save"|base_url}}",
            data        :   {
                ause_id        :   $("#ause_id").val(),
                ause_name      :   $("#ause_name").val(),
                ause_username  :   $("#ause_username").val(),
                ause_email     :   $("#ause_email").val(),
                ause_password  :   $("#ause_password").val(),
                ause_position  :   $("#ause_position").val(),
                ause_status    :   $("#ause_status").val()
            },
            datatype    :   "json",
            callback    :   function(data){
                if(data.result<0){
                    new bckdialog({type:'error'}).open(data.message);
                }else{
                    uiMessage(data.message);
                }
            }
        }).call();
        return false;
    }
</script>
{{include file="../include/04_foot.tpl"}}
